package com.xiaolin.jpademo.utils;

import lombok.Data;
import org.springframework.data.domain.Page;

import java.util.List;

/**
 * @ClassName PageUtils
 * @Description 分页工具类
 * @Detail detail
 * @Author MyPC
 * @Date 2021/1/10
 * @Version 1.0
 */
@Data
public class PageUtils<T> {
    private Integer pageNum;
    private Integer pageSize;
    private Integer pages;
    private Long totals;
    private List<T> list;
    public static <T> PageUtils<T> getPageObj(Page<T> page){
        PageUtils<T> pageUtils=new PageUtils<>();
        pageUtils.setPageNum(page.getNumber());
        pageUtils.setPageSize(page.getSize());
        pageUtils.setPages(page.getTotalPages());
        pageUtils.setTotals(page.getTotalElements());
        pageUtils.setList(page.getContent());
        return pageUtils;
    }
}
